// number: 0,1,2,3,4,5,6,7,8,9,. (count: 11)
// binary operator: +-*/%^ (count 6)
// control operator: =,del,clear,(,),←,→ (count 5)
// total 24
// layout:
// =expr======
// =======res=
// 7 8 9 % C D
// 4 5 6 + - ←
// 1 2 3 * / →
// 0 . ^ ( ) =

import { TextLineEdit } from "widgets/widgets.slint";
import { ColoSchemes as Schemes, Palette } from "widgets/styling.slint";
import { Button , GridBox} from "std-widgets.slint";
import { Button as SelfButton } from "widgets/widgets.slint";
export { Schemes }

component ExpressPanel inherits Rectangle {
    in-out property <string> input_text;
    in-out property <string> result_text;

    border-width: 2px;
    border-radius: 5px;
    border-color: #111111;

    VerticalLayout {
        padding: 20px;
        spacing: 10px;
        i-text-input := TextLineEdit {
            placeholder-text: "请输入算术式...";
            text: input_text;
            font-size: 18px;
        }
        TouchArea {
            i-text-result := TextLineEdit {
                width: 100%;
                height: 100%;
                horizontal-alignment: right;
                text: result_text;
                font-size: 16px;
                read-only: true;
            }
        }
    }
}

export component CalculatorWindow inherits Window {
    min-width: 400px;
    min-height: 400px;
    background: Palette.background;
    VerticalLayout {
        padding: 20px;
        i-express-panel := ExpressPanel {
            height: 30%;
            result-text: "res";
        }
        HorizontalLayout {
            for line in [["7", "4", "1", "0"], ["8", "5", "2", "."],["9", "6", "3", "^"],["%", "+", "*", "("],["C", "-", "/", ")"],["D", "←", "→", "="]]: VerticalLayout {
                for ch in line: Button {
                    callback click(string /* press symbol */);
                    text: ch;
                    clicked => {
                        click(ch);
                    }
                }
            }
        }
    }
}